<%@ include file="../common/top.jsp"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<div id="BackLink">
    <a href="mainForm">Return to Main Menu</a>
</div>

<div id="Catalog">

    <h2>Search Results for "${sessionScope.searchKeyword}"</h2>

    <c:if test="${empty sessionScope.productList}">
        <div class="no-results">
            <p>No products found matching your search criteria: <strong>"${sessionScope.searchKeyword}"</strong></p>
            <p>Please try a different search term.</p>
        </div>
    </c:if>

    <c:if test="${not empty sessionScope.productList}">
        <div class="results-info">
            Found ${sessionScope.productList.size()} products matching your search.
        </div>

        <table>
            <tr>
                <th>Product ID</th>
                <th>Name</th>
                <th>Description</th>
                <th>Category</th>
                <th>&nbsp;</th>
            </tr>
            <c:forEach var="product" items="${sessionScope.productList}">
                <tr>
                    <td>
                        <a href="productForm?productId=${product.productId}">${product.productId}</a>
                    </td>
                    <td>${product.name}</td>
                    <td>${product.description}</td>
                    <td>${product.categoryId}</td>
                    <td>
                        <a href="productForm?productId=${product.productId}" class="Button">View Items</a>
                    </td>
                </tr>
            </c:forEach>
        </table>
    </c:if>

    <div class="navigation">
        <a href="javascript:history.back()" class="Button">Back to Previous Page</a>
        <a href="mainForm" class="Button">Return to Main Menu</a>
    </div>

</div>
<%@ include file="../common/bottom.jsp"%>